package chalmers.game.subterranean.model;

import chalmers.game.subterranean.event.Bus;
import chalmers.game.subterranean.event.events.minors.MoveMinorEvent;
import chalmers.game.subterranean.model.physics.IMovableBody;
import chalmers.game.subterranean.model.physics.IPhysicsHandler;
import chalmers.game.subterranean.util.Direction;

/**
 * Dumb minors.
 * 
 * @author Alex Evert
 */
public class MinorsHandler implements IPhysicsHandler {

  public void moveMinor(IMovableBody body) {
    body.moveBody(this);
    Bus.INSTANCE.post(new MoveMinorEvent(body.hashCode(), body.getExactPosition()));
  }

  @Override
  public void bounce(IMovableBody body, Direction direction) {
    if (direction == Direction.SOUTH) {
      body.setYVelocity(0);
    } else {
      body.setXVelocity(-body.getXVelocity());
    }
  }

}
